<?php
$datos = array();
?>
<?php foreach ($summary as $key => $carrera): ?>
    <?php if ($key != 0): ?>
        <table>
            <tbody>
                <?php $anio = 1 ?>
                <?php foreach ($carrera as $key2 => $ubicacion): ?>
                    <?php if (fmod($key2, 2)): ?>
                        <tr class="udef">
                            <th colspan="3" style="background: #b7d2ff;">
                                <?php echo htmlentities(mb_strtoupper($ubicacion[0]['unidad_formacion'], 'UTF-8')) ?> - 
                                <?php echo $anio;
                                $anio++ ?> <?php echo htmlentities('º Año') ?>
                            </th>
                        </tr>
                        <tr class="header" style="background: #ededed;">
                            <td style="width: 25%;">Apellido</td>
                            <td style="width: 25%;">Nombre</td>
                            <td style="width: 30%;">Localidad</td>
                        </tr>
                    <?php endif ?>
                    <?php foreach ($ubicacion as $alumno): ?>
                        <tr>
                            <td><?php echo htmlentities(mb_strtoupper($alumno['apellido'], 'UTF-8')) ?></td>
                            <td><?php echo htmlentities(mb_strtoupper($alumno['nombre'], 'UTF-8')) ?></td>
                            <td><?php echo htmlentities(mb_strtoupper($alumno['localidad'], 'UTF-8')) ?></td>
                        </tr>
            <?php endforeach ?>
        <?php endforeach ?>
            </tbody>
        </table>
    <?php endif ?>
<?php endforeach ?>
<style>
    table { border-collapse: collapse; width: 100%; border: 1px solid #ccc; margin-bottom: 30px; }
    table.centered tbody tr td { text-align: center; }
    .udef { background: #cdcdcd; }
    .header { background: #ededed; }
</style>
